package com.aruba.attendance.activity

import android.annotation.SuppressLint
import android.content.Intent
import android.os.Bundle
import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.runtime.*
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import com.aruba.attendance.ui.theme.AttendanceApplicationTheme
import com.aruba.attendance.ui.widget.Logo
import com.aruba.attendance.ui.widget.statusbar.StatusBarSurface
import kotlinx.coroutines.delay

@SuppressLint("CustomSplashScreen")
class SplashActivity : ComponentActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContent {
            AttendanceApplicationTheme {
                StatusBarSurface(
                    modifier = Modifier.fillMaxSize(),
                    color = Color.White
                ) {
                    var visible by remember { mutableStateOf(false) }
                    LaunchedEffect(Unit) {
                        delay(100)
                        visible = true
                        delay(300)
                        startActivity(Intent(this@SplashActivity, MainActivity::class.java))
                        finish()
                    }

                    Logo(visible)
                }
            }
        }
    }
}
